Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for RepeatDataset #26415

Merged
merged 4 commits into from Mar 12, 2019

Conversation

feihugis
Copy link
Member

@feihugis feihugis commented Mar 7, 2019

This PR adds the test for the kernel of RepeatDataset.

cc @rachellim @jsimsa

@rthadur rthadur requested a review from jsimsa March 7, 2019 19:00
@rthadur rthadur self-assigned this Mar 7, 2019
@rthadur rthadur added this to Assigned Reviewer in PR Queue via automation Mar 7, 2019
@rthadur rthadur added the size:L CL Change Size: Large label Mar 7, 2019
NodeDef node_def_;
};

struct TestParam {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/TestParam/TestCase

};

// Test case 1: finite repetition.
TestParam TestCase1() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/TestCase1/FiniteRepeatTestCase/ ... and similarly for the other test cases

return Status::OK();
}

Status CreateDatasetFromTestCase(const TestParam &test_case) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for FromTestCase

return Status::OK();
}

Status CreateIteratorFromTestCase(const TestParam &test_case) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for FromTestCase

return Status::OK();
}

std::unique_ptr<OpKernel> dataset_kernel_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid storing this state in member variables. There is no need to do this and it hurts readability.

std::vector<Tensor> out_tensors;

if (test_case.count < 0) {
int fake_infinite_repetition = 100;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of a cryptic variable name, add a comment here that says that we test only test a finite number of steps of the infinite sequence, and then use a for loop.

PR Queue automation moved this from Assigned Reviewer to Reviewer Requested Changes Mar 8, 2019
Copy link
Contributor

@jsimsa jsimsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feihugis thank you for the PR, I did a pass and left some comments

- Change the class name and function name to improve readability
- Remove dataset_kernel_ member variable
- Refactor the forever repeat test
@feihugis
Copy link
Member Author

@jsimsa Thanks for your review! The comments are addressed in this commit. Could you have a look when you have time?

Copy link
Contributor

@jsimsa jsimsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feihugis thank you for the changes, one more comment

TF_RETURN_IF_ERROR(
CreateIteratorContext(dataset_kernel_ctx_.get(), &iterator_ctx_));
TF_RETURN_IF_ERROR(
dataset_->MakeIterator(iterator_ctx_.get(), "Iterator", &iterator_));
return Status::OK();
}

std::unique_ptr<OpKernel> dataset_kernel_;
std::unique_ptr<OpKernelContext> dataset_kernel_ctx_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment was meant for all of the internal state (dataset_kernel_, dataset_kernel_ctx_, and iterator_ctx_).

While writing the code this way makes it less verbose, it makes it harder to understand what is going on in case someone would like to modify the code.

@feihugis
Copy link
Member Author

@jsimsa This commit removes the internal member variables, and move the code in the helper class to each test to improve the code readability. Could you have a look at the changes? Any suggestions are very welcome.

PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Mar 11, 2019
@rthadur rthadur added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Mar 11, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Mar 11, 2019
@tensorflow-copybara tensorflow-copybara merged commit 4ac1f45 into tensorflow:master Mar 12, 2019
PR Queue automation moved this from Approved by Reviewer to Merged Mar 12, 2019
tensorflow-copybara pushed a commit that referenced this pull request Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes ready to pull PR ready for merge process size:L CL Change Size: Large
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

6 participants